﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using EntityFrameworkCore.UseRowNumberForPaging;

namespace Qianke.Core.Saas.EntityFramework
{
    public static class SaasServiceDbContextExtensions
    {
        public static void AddQiankeSaasDbContext<TDbContext>(this IServiceCollection services)
            where TDbContext : AbpDbContext<TDbContext>
        {
            services.AddAbpDbContext<TDbContext>(options =>
            {
                options.AddDefaultRepositories(true);
            })
            .Configure<AbpDbContextOptions>(options =>
            {
                options.UseSqlServer(i =>
                {
                    i.UseRowNumberForPaging();
                    i.UseCompatibilityLevel(100);// SQL Server 2008 R2 的兼容性等级为 100
                });
            });
        }
    }
}
